package com.resou.reader.mine.vipcenter.adapter;

import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.resou.reader.R;
import com.resou.reader.bookdetail.BookDetailActivity;
import com.resou.reader.data.bookstore.model.PlateNovels;

import java.util.List;

/**
 * 换一换适配器
 */
public class MonthlyVipGridAdapter extends BaseQuickAdapter<PlateNovels, BaseViewHolder> {
    public MonthlyVipGridAdapter(int layoutResId, @Nullable List<PlateNovels> data) {
        super(layoutResId, data);
    }

    public MonthlyVipGridAdapter(@Nullable List<PlateNovels> data) {
        super(data);
    }

    @Override
    protected void convert(BaseViewHolder helper, PlateNovels item) {
        Glide.with(mContext).load(item.getCoverUrl() + "").into((ImageView) helper.getView(R.id.ivBookPic));
        helper.addOnClickListener(R.id.llOnclick_Grid).setText(R.id.tvBookName, item.getNovelName())
                .setText(R.id.tvMoney, item.getCnyPrice() + "");
        TextView price = helper.getView(R.id.tvMoney);
        price.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        LinearLayout linearLayout = helper.getView(R.id.llOnclick_Grid);
        linearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                BookDetailActivity.startDetailActivity(mContext, item.getNovelId());
            }
        });
    }
}
